package com.rimi.model.dto;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.rimi.bean.Pets;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;

/**
 * @author liHaiYang
 * @version V1.0
 * @Description: (用一句话描述该文件做什么)
 * @date 2021/7/7 10:26
 */
@Data
@ApiModel("宠物信息")
public class PetsListDto {

    @ApiModelProperty("宠物年龄")
    private Double age;

    @ApiModelProperty("宠物ID")
    private Integer petId;

    @ApiModelProperty("宠物性别")
    private String petSex;

    @ApiModelProperty("宠物类")
    private String petType;

    @ApiModelProperty("宠物昵称")
    private String petNickname;

    @ApiModelProperty("宠物生日")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date petBirthday;

    @ApiModelProperty("宠物体重")
    private double petWeight;

    @ApiModelProperty("是否绝育")
    private String petSterilization;

    @ApiModelProperty("宠物描述")
    private String petDescribe;

    @ApiModelProperty("宠物头像")
    private String petHeaderImg;

    @ApiModelProperty("用户ID")
    private Integer userId;

    public Double getAge(){
        Date date = new Date();
        if(petBirthday != null){
            int day = (int) ((date.getTime() - petBirthday.getTime()) / 1000 / 60 / 60 / 24);
//            return (int) (day / 365.0 * 10) / 10.0;
            return (int) Math.round(day / 365.0 * 10) / 10.0;
        }
        return null;
    }
}


